package com.ld.front.controller;

import java.util.Map;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.ld.shieldsb.common.core.model.PropertiesModel;

import springfox.documentation.annotations.ApiIgnore;

@ApiIgnore() // 这个类下写的方法于类或者方法上，可以不被swagger显示在页面上
@Controller
@RequestMapping("${shieldsb.frontPath}")
public class IndexController extends FrontBasicController<Object> {
    private static final String SWAGGER_UI_DEFAULT = "/swagger-ui.html"; // swagger-ui.html 的页面
    private static final String SWAGGER_UI_LAYER = "/docs.html"; // swagger-ui.html 的页面
    private static final String SWAGGER_UI_BOOTSTRAP = "/doc.html"; // swagger-ui.html 的页面,进行了重写，取消了返回全部接口的功能，只显示默认，即前台接口

    @RequestMapping({ "", "/", "/index" })
    public String index(Map<String, Object> map) {
        // 跳转到对应的 接口列表
        String swaggerUi = PropertiesModel.CONFIG.getString("swaggerUi", SWAGGER_UI_BOOTSTRAP);
        if (swaggerUi.equals("bootstrap")) {
            swaggerUi = SWAGGER_UI_BOOTSTRAP;
        } else if (swaggerUi.equals("layui")) {
            swaggerUi = SWAGGER_UI_LAYER;
        } else if (swaggerUi.equals("swagger")) {
            swaggerUi = SWAGGER_UI_DEFAULT;
        } else { // 什么都没有 默认bootstrap
            swaggerUi = SWAGGER_UI_BOOTSTRAP;
        }
        return REDIRECT + swaggerUi;
    }

}
